﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MagicCove
{
    //Definition for creating each card

    //Note that sE's and iP's will be linked so the must be in the specified order. First

    //It is better to list the mana on a card in backwards order as it will be more effecient while running the program (though not much). Either way will work though
    class CardDefLibrary
    {
        public static MagicCard getCardByString(String switchString, Player owner)
        {
            switch (switchString)
            {/*Template definition
              * case "~!~Card Name":
                    return new MagicCard(switchString, owner, CardSupertype.X, CardType.X, CardSubtype.X, X, X, false, new iP(new List<ManaType> { X }), new List<sEBase> { X }, new List<sEBase> { X });
              */
                #region Artifacts (0)
                #endregion
                #region Creatures (1)
                case "Accorder Paladin":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Creature, CardSubtype.Human | CardSubtype.Knight, 3, 1, new iPACEPST(new List<ManaType> { ManaType.White, ManaType.Colorless }), new List<sEBase> { }, new List<sEBase> { new sEBattleCry(new iPIsAttacking()) });
                case "Ardent Recruit":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Creature, CardSubtype.Human | CardSubtype.Soldier, 1, 1, new iPACEPST(new List<ManaType> { ManaType.White }), new List<sEBase> { }, new List<sEBase> { new sEPlusXPlusY(new iPMetalcraftTriggered(), 2, 2) });
                case "Brindle Boar":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Creature, CardSubtype.Boar, 2, 2, new iPACEPST(new List<ManaType> { ManaType.Green, ManaType.TwoColorless }), new List<sEBase> { new sEGainLife(new iPSacrificeCard(), 4) }, new List<sEBase> { });
                case "Coral Merfolk":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Creature, CardSubtype.Merfolk, 2, 1, new iPACEPST(new List<ManaType> { ManaType.Blue, ManaType.Colorless }), new List<sEBase> { }, new List<sEBase> { });
                //case "Hero of Bladehold":
                    //return new MagicCard(switchString, owner, CardSupertype.None, CardType.Creature, CardSubtype.Human | CardSubtype.Knight, 3, 4, new iPACEPST(new List<ManaType> { ManaType.White, ManaType.White, ManaType.TwoColorless }), new List<sEBase> { }, new List<sEBase> { new sEBattleCry(new iPIsAttacking),  });
                case "Wall of Omens": //~!~ This card is not stardard
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Creature, CardSubtype.Wall, 0, 4, new iPACEPST(new List<ManaType> { ManaType.White, ManaType.Colorless }), new List<sEBase> { }, new List<sEBase> { new sEDefender(new iPAlways()), new sEDrawCard(new iPEntersField()) });
                #endregion
                #region Enchantments (2)
                #endregion
                #region Instants (3)
                    //Instants generally have an triggered effect which is always playable
                case "Banishment Decree":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Instant, CardSubtype.None, 0, 0, new iPTargetTypes(new List<ManaType> { ManaType.White, ManaType.White, ManaType.ThreeColorless }, CardType.Artifact | CardType.Creature | CardType.Enchantment, CardType.None, new List<int> { 1 }), new List<sEBase> { }, new List<sEBase> { new sEMoveToDeck(new iPResolvingFromStack(), true, false) });
                case "Choking Fumes":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Instant, CardSubtype.None, 0, 0, new iPAttackingCreatures(new List<ManaType> { ManaType.White, ManaType.TwoColorless }), new List<sEBase> { }, new List<sEBase> { new sEPutMinusOneCounters(new iPResolvingFromStack(), 1) });
                case "Crush":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Instant, CardSubtype.None, 0, 0, new iPTargetTypes(new List<ManaType> { ManaType.Red }, CardType.Artifact, CardType.Creature, new List<int> { 1 }), new List<sEBase> { }, new List<sEBase> { new sEDestroyTarget(new iPResolvingFromStack()) });
                case "Divine Offering":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Instant, CardSubtype.None, 0, 0, new iPTargetTypes(new List<ManaType> { ManaType.White, ManaType.Colorless }, CardType.Artifact, CardType.None, new List<int> { 1 }), new List<sEBase> { }, new List<sEBase> { new sEDestroyTarget(new iPResolvingFromStack()), new sEGainLife(new iPResolvingFromStack(), false, false, true) });
                case "Frantic Salvage":
                    return new MagicCard(switchString, owner, CardSupertype.None, CardType.Instant, CardSubtype.None, 0, 0, new iPTargetTypes(new List<ManaType> { ManaType.White, ManaType.ThreeColorless }, CardType.Artifact, CardType.None, new List<int> { }, TargetLocation.CurrentPlayersGraveyard), new List<sEBase> { }, new List<sEBase> { new sEMoveToDeck(new iPResolvingFromStack(), true, false) });
                #endregion
                #region Lands (4)
                case "Plains":
                    return new MagicCard(switchString, owner, CardSupertype.Basic, CardType.Land, CardSubtype.Plains, 0, 0, new iPLandPlay(), new List<sEBase> { new sEPlains(new iPManaAbility()) }, new List<sEBase> { });
                case "Island":
                    return new MagicCard(switchString, owner, CardSupertype.Basic, CardType.Land, CardSubtype.Island, 0, 0, new iPLandPlay(), new List<sEBase> { new sEIsland(new iPManaAbility()) }, new List<sEBase> { });
                case "Swamp":
                    return new MagicCard(switchString, owner, CardSupertype.Basic, CardType.Land, CardSubtype.Swamp, 0, 0, new iPLandPlay(), new List<sEBase> { new sESwamp(new iPManaAbility()) }, new List<sEBase> { });
                case "Mountain":
                    return new MagicCard(switchString, owner, CardSupertype.Basic, CardType.Land, CardSubtype.Mountain, 0, 0, new iPLandPlay(), new List<sEBase> { new sEMountain(new iPManaAbility()) }, new List<sEBase> { });
                case "Forest":
                    return new MagicCard(switchString, owner, CardSupertype.Basic, CardType.Land, CardSubtype.Forest, 0, 0, new iPLandPlay(), new List<sEBase> { new sEForest(new iPManaAbility()) }, new List<sEBase> { });
                #endregion
                #region Planeswalkers (5)
                #endregion
                #region Sorcery (6)
                #endregion
                #region Tribal (7)
                #endregion
                #region Tokens
                //case "Soldier 1/1":
                    //return new
                #endregion
                default:
                    return null;
            }
        }
        public static MagicCard getGenericCardByString(String cardName, Player owner)
        {//a card that can always be played. Used for creating the deck in the non-rule enforced game
            return new MagicCard(cardName, owner, CardSupertype.None, CardType.None, CardSubtype.None, 0, 0, new iPAlways(), new List<sEBase> { }, new List<sEBase> { });
        }
        public static String getTokenStringByNumber(int number)
        {//tokens are organized alphabetically within the latest set the came out, this functions allows a for loop to easily download all the token images
            switch (number)
            {//Note if this library is changed we need to change get tokenImageURLByNumber and the total token in initializeHT
                #region New Phyrexia
                case 0:
                    return "Beast 3/3";
                case 1:
                    return "Goblin 1/1";
                case 2:
                    return "Golem 3/3";
                case 3:
                    return "Myr 1/1";
                #endregion
                #region Mirrodin Besieged
                case 4:
                    return "Germ 0/0";
                case 5:
                    return "Zombie 2/2";
                case 6:
                    return "Golem 9/9";
                case 7:
                    return "Horror */*";
                case 8:
                    return "Thopter 1/1";
                #endregion
                #region Scars of Mirrodin
                case 9:
                    return "Cat 2/2";
                case 10:
                    return "Soldier 1/1";
                case 11:
                    return "Insect 1/1";
                case 12:
                    return "Wolf 2/2";
                case 13:
                    return "Wurm 1 3/3";
                case 14:
                    return "Wurm 2 3/3";
                #endregion
                #region Magic 2011
                case 15:
                    return "Avatar */*";
                case 16:
                    return "Bird 3/3";
                case 17:
                    return "Ooze 1 2/2";
                case 18:
                    return "Ooze 2 1/1";
                #endregion
                #region Rise of the Eldrazi
                case 19:
                    return "Eldrazi Spawn 1 0/1";
                case 20:
                    return "Elemental */*";
                case 21:
                    return "Hellion 4/4";
                case 22:
                    return "Ooze */*";
                case 23:
                    return "Tuktuk the Returned 5/5";
                #endregion
                #region Duel Decks: Phyrexia vs. The Coalition
                case 24:
                    return "Hornet 1/1";
                case 25:
                    return "Minion */*";
                case 26:
                    return "Saproling 1/1";
                #endregion
                #region Worldwake
                case 27:
                    return "Soldier Ally 1/1";
                case 28:
                    return "Dragon 5/5";
                case 29:
                    return "Ogre 3/3";
                case 30:
                    return "Elephant 3/3";
                case 31:
                    return "Plant 0/1";
                case 32:
                    return "Construct 6/12";
                #endregion
                default:
                    return null;
            }
        }
        public static String getTokenImageURLByNumber(int number)
        {
            String baseUrl = "http://magiccards.info/extras/token/";
            String baseJpg = getTokenStringByNumber(number);
            baseJpg = baseJpg.Substring(0, baseJpg.IndexOf("/") - 2);
            baseJpg = baseJpg.ToLower();
            baseJpg = baseJpg.Replace(" ", "-");
            //based on where the regions are above
            if (number < 4)
                baseUrl = baseUrl + "new-phyrexia";
            else if (number < 9)
                baseUrl = baseUrl + "mirrodin-besieged";
            else if (number < 15)
                baseUrl = baseUrl + "scars-of-mirrodin";
            else if (number < 19)
                baseUrl = baseUrl + "magic-2011";
            else if (number < 24)
                baseUrl = baseUrl + "rise-of-the-eldrazi";
            else if (number < 27)
                baseUrl = baseUrl + "duel-decks-phyrexia-vs-the-coalition";
            else if (number < 33)
                baseUrl = baseUrl + "worldwake";
            return baseUrl + "/" + baseJpg + ".jpg";
        }
    }
}
